home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio / Ham Radio CD-ROM (Emerald Software) (1995).ISO / misc / 9q920411 / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-11  |  20.9 KB  |  929 lines

  1. /* A collection of stuff heavily dependent on the configuration info
  2.  * in config.h. The idea is that configuration-dependent tables should
  3.  * be located here to avoid having to pepper lots of .c files with #ifdefs,
  4.  * requiring them to include config.h and be recompiled each time config.h
  5.  * is modified.
  6.  *
  7.  * Copyright 1991 Phil Karn, KA9Q
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include <dos.h>
  12. #include "global.h"
  13. #include "config.h"
  14. #include "mbuf.h"
  15. #include "timer.h"
  16. #include "proc.h"
  17. #include "iface.h"
  18. #include "ip.h"
  19. #include "tcp.h"
  20. #include "udp.h"
  21. #ifdef    ARCNET
  22. #include "arcnet.h"
  23. #endif
  24. #include "lapb.h"
  25. #include "ax25.h"
  26. #include "enet.h"
  27. #include "kiss.h"
  28. #include "nr4.h"
  29. #include "nrs.h"
  30. #include "netrom.h"
  31. #include "pktdrvr.h"
  32. #include "ppp.h"
  33. #include "slip.h"
  34. #include "arp.h"
  35. #include "icmp.h"
  36. #include "hardware.h"    /***/
  37. #include "usock.h"
  38. #include "cmdparse.h"
  39. #include "commands.h"
  40. #include "mailbox.h"
  41. #include "ax25mail.h"
  42. #include "nr4mail.h"
  43. #include "tipmail.h"
  44. #include "daemon.h"
  45. #include "bootp.h"
  46. #include "asy.h"
  47.  
  48. int dotest __ARGS((int argc,char *argv[],void *p));    /**/
  49. static int dostart __ARGS((int argc,char *argv[],void *p));
  50. static int dostop __ARGS((int argc,char *argv[],void *p));
  51.  
  52. #ifdef    AX25
  53. static void axip __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  54.     char *dest,struct mbuf *bp,int mcast));
  55. static void axarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  56.     char *dest,struct mbuf *bp,int mcast));
  57. static void axnr __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  58.     char *dest,struct mbuf *bp,int mcast));
  59. #endif
  60.  
  61. struct mbuf *Hopper;
  62. unsigned Nsessions = NSESSIONS;
  63. int Nusock = DEFNSOCK;        /* Number of socket entries */
  64.  
  65. /* Free memory threshold, below which things start to happen to conserve
  66.  * memory, like garbage collection, source quenching and refusing connects
  67.  */
  68. int32 Memthresh = MTHRESH;
  69.  
  70. int Nibufs = NIBUFS;        /* Number of interrupt buffers */
  71. unsigned Ibufsize = IBUFSIZE;    /* Size of each interrupt buffer */
  72.  
  73. /* Socket-protocol interface table */
  74. struct socklink Socklink[] = {
  75.     /* type,
  76.      * socket,    bind,        listen,        connect,
  77.      * accept,    recv,        send,        qlen,
  78.      * kick,    shut,        close,        check,
  79.      * error,    state,        status
  80.      */
  81.     TYPE_TCP,
  82.     so_tcp,        NULLFP,        so_tcp_listen,    so_tcp_conn,
  83.     TRUE,        so_tcp_recv,    so_tcp_send,    so_tcp_qlen,
  84.     so_tcp_kick,    so_tcp_shut,    so_tcp_close,    checkipaddr,
  85.     Tcpreasons,    tcpstate,    so_tcp_stat,
  86.  
  87.     TYPE_UDP,
  88.     so_udp,        so_udp_bind,    NULLFP,        so_udp_conn,
  89.     FALSE,        so_udp_recv,    so_udp_send,    so_udp_qlen,
  90.     NULLFP,        NULLFP,        so_udp_close,    checkipaddr,
  91.     NULL,        NULLFP,        so_udp_stat,
  92.  
  93. #ifdef    AX25
  94.     TYPE_AX25I,
  95.     so_ax_sock,    NULLFP,        so_ax_listen,    so_ax_conn,
  96.     TRUE,        so_ax_recv,    so_ax_send,    so_ax_qlen,
  97.     so_ax_kick,    so_ax_shut,    so_ax_close,    checkaxaddr,
  98.     Axreasons,    axstate,    so_ax_stat,
  99.  
  100.     TYPE_AX25UI,
  101.     so_axui_sock,    so_axui_bind,    NULLFP,        so_axui_conn,
  102.     FALSE,        so_axui_recv,    so_axui_send,    so_axui_qlen,
  103.     NULLFP,        NULLFP,        so_axui_close,    checkaxaddr,
  104.     NULL,        NULLFP,        NULLFP,
  105. #endif
  106.     TYPE_RAW,
  107.     so_ip_sock,    NULLFP,        NULLFP,        so_ip_conn,
  108.     FALSE,        so_ip_recv,    so_ip_send,    so_ip_qlen,
  109.     NULLFP,        NULLFP,        so_ip_close,    checkipaddr,
  110.     NULL,        NULLFP,        NULLFP,
  111.  
  112. #ifdef    NETROM
  113.     TYPE_NETROML3,
  114.     so_n3_sock,    NULLFP,        NULLFP,        so_n3_conn,
  115.     FALSE,        so_n3_recv,    so_n3_send,    so_n3_qlen,
  116.     NULLFP,        NULLFP,        so_n3_close,    checknraddr,
  117.     NULL,        NULLFP,        NULLFP,
  118.  
  119.     TYPE_NETROML4,
  120.     so_n4_sock,    NULLFP,        so_n4_listen,    so_n4_conn,
  121.     TRUE,        so_n4_recv,    so_n4_send,    so_n4_qlen,
  122.     so_n4_kick,    so_n4_shut,    so_n4_close,    checknraddr,
  123.     Nr4reasons,    nrstate,    so_n4_stat,
  124. #endif
  125.     TYPE_LOCAL_STREAM,
  126.     so_los,        NULLFP,        NULLFP,        NULLFP,
  127.     TRUE,        so_lo_recv,    so_los_send,    so_los_qlen,
  128.     NULLFP,        so_loc_shut,    so_loc_close,    NULLFP,
  129.     NULL,        NULLFP,        so_loc_stat,
  130.  
  131.     TYPE_LOCAL_DGRAM,
  132.     so_lod,        NULLFP,        NULLFP,        NULLFP,
  133.     FALSE,        so_lo_recv,    so_lod_send,    so_lod_qlen,
  134.     NULLFP,        so_loc_shut,    so_loc_close,    NULLFP,
  135.     NULL,        NULLFP,        so_loc_stat,
  136.  
  137.     -1
  138. };
  139. char * (*Psock[]) () = {
  140.     ippsocket,
  141.     axpsocket,
  142.     nrpsocket,
  143.     lopsocket,
  144. };
  145.  
  146. /* Functions to handle incoming link-level frames */
  147. struct rfunc Rfunc[] = {
  148. #ifdef    ETHER
  149.     CL_ETHERNET,    eproc,
  150. #endif
  151. #ifdef    ARCNET
  152.     CL_ARCNET,    aproc,
  153. #endif
  154. #ifdef    KISS
  155.     CL_KISS,    kiss_recv,
  156. #endif
  157. #ifdef    AX25
  158.     CL_AX25,    ax_recv,
  159. #endif
  160. #ifdef    PPP
  161.     CL_PPP,        ppp_proc,
  162. #endif
  163.     /* These types have no link layer protocol at the point when they're
  164.      * put in the hopper, so they can be handed directly to IP. The
  165.      * separate types are just for user convenience when running the
  166.      * "iface" command.
  167.      */
  168.     CL_NONE,    ip_proc,
  169.     CL_SERIAL_LINE,    ip_proc,
  170.     CL_SLFP,    ip_proc,
  171.     -1,        NULL,
  172. };
  173. /* Transport protocols atop IP */
  174. struct iplink Iplink[] = {
  175.     TCP_PTCL,    tcp_input,
  176.     UDP_PTCL,    udp_input,
  177.     ICMP_PTCL,    icmp_input,
  178.     IP_PTCL,    ipip_recv,
  179.     0,        0
  180. };
  181.  
  182. /* Transport protocols atop ICMP */
  183. struct icmplink Icmplink[] = {
  184.     TCP_PTCL,    tcp_icmp,
  185.     0,        0
  186. };
  187.  
  188. /* ARP protocol linkages */
  189. struct arp_type Arp_type[NHWTYPES] = {
  190. #ifdef    NETROM
  191.     AXALEN, 0, 0, 0, NULLCHAR, pax25, setcall,    /* ARP_NETROM */
  192. #else
  193.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  194. #endif
  195.  
  196. #ifdef    ETHER
  197.     EADDR_LEN,IP_TYPE,ARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  198. #else
  199.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  200. #endif
  201.  
  202.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_EETHER */
  203.  
  204. #ifdef    AX25
  205.     AXALEN, PID_IP, PID_ARP, 10, Ax25multi[0], pax25, setcall,
  206. #else
  207.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_AX25 */
  208. #endif
  209.  
  210.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_PRONET */
  211.  
  212.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_CHAOS */
  213.  
  214.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_IEEE802 */
  215.  
  216. #ifdef    ARCNET
  217.     AADDR_LEN, ARC_IP, ARC_ARP, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  218. #else
  219.     0, 0, 0, 0, NULLCHAR,NULL,NULL,
  220. #endif
  221.  
  222.     0, 0, 0, 0, NULLCHAR,NULL,NULL,            /* ARP_APPLETALK */
  223. };
  224.  
  225. #ifdef    AX25
  226. /* Linkage to network protocols atop ax25 */
  227. struct axlink Axlink[] = {
  228.     PID_IP,        axip,
  229.     PID_ARP,    axarp,
  230. #ifdef    NETROM
  231.     PID_NETROM,    axnr,
  232. #endif
  233.     PID_NO_L3,    axnl3,
  234.     0,        NULL,
  235. };
  236. #endif
  237.  
  238. /* TCP port numbers to be considered "interactive" by the IP routing
  239.  * code and given priority in queueing
  240.  */
  241. int Tcp_interact[] = {
  242.     IPPORT_FTP,    /* FTP control (not data!) */
  243.     IPPORT_TELNET,    /* Telnet */
  244.     IPPORT_LOGIN,    /* BSD rlogin */
  245.     IPPORT_MTP,    /* Secondary telnet */
  246.     -1
  247. };
  248.  
  249. #ifdef    ASY
  250. struct asymode Asymode[] = {
  251. #ifdef    SLIP
  252.     "SLIP",    FR_END,        slip_init, slip_free,
  253. #endif
  254. #ifdef    KISS
  255.     "AX25",    FR_END,        kiss_init, kiss_free,
  256. #endif
  257. #ifdef    NRS
  258.     "NRS",    ETX,        nrs_init, nrs_free,
  259. #endif
  260. #ifdef    PPP
  261.     "PPP",    HDLC_FLAG,    ppp_init, ppp_free,
  262. #endif
  263.     NULLCHAR
  264. };
  265. #endif    /* ASY */
  266.  
  267. #ifdef    MAILBOX
  268. void (*Listusers) __ARGS((int s)) = listusers;
  269. #else
  270. void (*Listusers) __ARGS((int s)) = NULL;
  271. #endif    /* MAILBOX */
  272.  
  273. #ifndef    BOOTP
  274. int WantBootp = 0;
  275.  
  276. int
  277. bootp_validPacket(ip,bpp)
  278. struct ip *ip;
  279. struct mbuf **bpp;
  280. {
  281.     return 0;
  282. }
  283. #endif    /* BOOTP */
  284.  
  285. /* daemons to be run at startup time */
  286. struct daemon Daemons[] = {
  287.     "killer",    512,    killer,
  288.     "gcollect",    256,    gcollect,
  289.     "timer",    1024,    timerproc,
  290.     "network",    1536,    network,
  291.     "keyboard",    250,    keyboard,
  292.     NULLCHAR,    0,    NULLVFP
  293. };
  294.  
  295. struct iftype Iftypes[] = {
  296.     /* This entry must be first, since Loopback refers to it */
  297.     "None",        NULL,        NULL,        NULL,
  298.     NULL,        CL_NONE,    0,
  299.  
  300. #ifdef    AX25
  301.     "AX25",        ax_send,    ax_output,    pax25,
  302.     setcall,    CL_AX25,    AXALEN,
  303. #endif
  304.  
  305. #ifdef    SLIP
  306.     "SLIP",        slip_send,    NULL,        NULL,
  307.     NULL,        CL_NONE,    0,
  308. #endif
  309.  
  310. #ifdef    ETHER
  311.     /* Note: NULL is specified for the scan function even though
  312.      * gether() exists because the packet drivers don't support
  313.      * address setting.
  314.      */
  315.     "Ethernet",    enet_send,    enet_output,    pether,
  316.     NULL,        CL_ETHERNET,    EADDR_LEN,
  317. #endif
  318.  
  319. #ifdef    NETROM
  320.     "NETROM",    nr_send,    NULL,        pax25,
  321.     setcall,    CL_NETROM,    AXALEN,
  322. #endif
  323.  
  324. #ifdef    SLFP
  325.     "SLFP",        pk_send,    NULL,        NULL,
  326.     NULL,        CL_NONE,    0,
  327. #endif
  328.  
  329. #ifdef    PPP
  330.     "PPP",        ppp_send,    ppp_output,    NULL,
  331.     NULL,        CL_PPP,    0,
  332. #endif
  333.  
  334.     NULLCHAR
  335. };
  336.  
  337. /* Command lookup and branch tables */
  338. struct cmds Cmds[] = {
  339.     /* The "go" command must be first */
  340.     "",        go,        0, 0, NULLCHAR,
  341. #ifndef    AMIGA
  342.     "!",        doshell,    0, 0, NULLCHAR,
  343. #endif
  344.     "abort",    doabort,    0, 0, NULLCHAR,
  345. #ifdef    AMIGA
  346.     "amiga",    doamiga,    0, 0, NULLCHAR,
  347. #endif
  348. #if    (defined(MAC) && defined(APPLETALK))
  349.     "applestat",    doatstat,    0,    0, NULLCHAR,
  350. #endif
  351. #if    (defined(AX25) || defined(ETHER) || defined(APPLETALK))
  352.     "arp",        doarp,        0, 0, NULLCHAR,
  353. #endif
  354. #ifdef    ASY
  355.     "asystat",    doasystat,    0, 0, NULLCHAR,
  356. #endif
  357.     "attach",    doattach,    0, 2,
  358.         "attach <hardware> <hw specific options>",
  359. #ifdef    AX25
  360.     "ax25",        doax25,        0, 0, NULLCHAR,
  361. #endif
  362. #ifdef    BOOTP
  363.     "bootp",    dobootp,    0, 0, NULLCHAR,
  364.     "bootpd",    bootpdcmd,    0, 0, NULLCHAR,
  365. #endif
  366. /* This one is out of alpabetical order to allow abbreviation to "c" */
  367. #ifdef    AX25
  368.     "connect",    doconnect,    1024, 3,
  369.     "connect <interface> <callsign>",
  370. #endif
  371. #if    !defined(UNIX) && !defined(AMIGA)
  372.     "cd",        docd,        0, 0, NULLCHAR,
  373. #endif
  374.     "close",    doclose,    0, 0, NULLCHAR,
  375. /* This one is out of alpabetical order to allow abbreviation to "d" */
  376.     "disconnect",    doclose,    0, 0, NULLCHAR,
  377.     "delete",    dodelete,    0, 2, "delete <file>",
  378.     "detach",    dodetach,    0, 2, "detach <interface>",
  379. #ifdef    DIALER
  380.     "dialer",    dodialer,    0, 2,
  381.     "dialer <iface> <timeout> [<raise script> <lower script>]",
  382. #endif
  383. #ifndef    AMIGA
  384.     "dir",        dodir,        512, 0, NULLCHAR, /* note sequence */
  385. #endif
  386.     "domain",    dodomain,    0, 0, NULLCHAR,
  387. #ifdef    DRSI
  388.     "drsistat",    dodrstat,    0, 0, NULLCHAR,
  389. #endif
  390. #ifdef    EAGLE
  391.     "eaglestat",    doegstat,    0, 0, NULLCHAR,
  392. #endif
  393.     "echo",        doecho,        0, 0, NULLCHAR,
  394.     "eol",        doeol,        0, 0, NULLCHAR,
  395. #if    !defined(MSDOS)
  396.     "escape",    doescape,    0, 0, NULLCHAR,
  397. #endif
  398.     "exit",        doexit,        0, 0, NULLCHAR,
  399.     "finger",    dofinger,    1024, 2, "finger name@host",
  400.     "ftp",        doftp,        2048, 2, "ftp <address>",
  401. #ifdef HAPN
  402.     "hapnstat",    dohapnstat,    0, 0, NULLCHAR,
  403. #endif
  404.     "help",        dohelp,        0, 0, NULLCHAR,
  405. #ifdef    HOPCHECK
  406.     "hop",        dohop,        0, 0, NULLCHAR,
  407. #endif
  408.     "hostname",    dohostname,    0, 0, NULLCHAR,
  409. #ifdef    HS
  410.     "hs",        dohs,        0, 0, NULLCHAR,
  411. #endif
  412.     "icmp",        doicmp,        0, 0, NULLCHAR,
  413.     "ifconfig",    doifconfig,    0, 0, NULLCHAR,
  414.     "ip",        doip,        0, 0, NULLCHAR,
  415. #ifdef    MSDOS
  416.     "isat",        doisat,        0, 0, NULLCHAR,
  417. #endif
  418.     "kick",        dokick,        0, 0, NULLCHAR,
  419.     "log",        dolog,        0, 0, NULLCHAR,
  420. #ifdef    MAILBOX
  421.     "mbox",        dombox,        0, 0, NULLCHAR,
  422. #endif
  423. #ifndef    UNIX
  424.     "memory",    domem,        0, 0, NULLCHAR,
  425. #endif
  426.     "mkdir",    domkd,        0, 2, "mkdir <directory>",
  427. #ifdef    AX25
  428.     "mode",        domode,        0, 2, "mode <interface>",
  429. #endif
  430.     "more",        domore,        512, 2, "more <filename>",
  431. #ifdef    NETROM
  432.     "netrom",    donetrom,    0, 0, NULLCHAR,
  433. #endif    /* NETROM */
  434. #ifdef    NNTP
  435.     "nntp",        donntp,        0, 0, NULLCHAR,
  436. #endif    /* NNTP */
  437. #ifdef    NRS
  438.     "nrstat",    donrstat,    0, 0, NULLCHAR,
  439. #endif    /* NRS */
  440.     "param",    doparam,    0, 2, "param <interface>",
  441.     "ping",        doping,        512, 2,
  442.     "ping <hostid> [<length> [<interval> [incflag]]]",
  443. #ifdef    PI
  444.     "pistatus",    dopistat,    0, 0, NULLCHAR,
  445. #endif
  446. #ifdef POP
  447.     "pop",        dopop,        0, 0, NULLCHAR,
  448. #endif
  449. #ifdef PPP
  450.     "ppp",        doppp_commands,    0, 0, NULLCHAR,
  451. #endif
  452.     "ps",        ps,        0, 0, NULLCHAR,
  453. #if    !defined(UNIX) && !defined(AMIGA)
  454.     "pwd",        docd,        0, 0, NULLCHAR,
  455. #endif
  456.     "record",    dorecord,    0, 0, NULLCHAR,
  457.     "remote",    doremote,    0, 3, "remote [-p port] [-k key] [-a kickaddr] <address> exit|reset|kick",
  458.     "rename",    dorename,    0, 3, "rename <oldfile> <newfile>",
  459.     "reset",    doreset,    0, 0, NULLCHAR,
  460. #ifdef    RIP
  461.     "rip",        dorip,        0, 0, NULLCHAR,
  462. #endif
  463.     "rmdir",    dormd,        0, 2, "rmdir <directory>",
  464.     "route",    doroute,    0, 0, NULLCHAR,
  465.     "session",    dosession,    0, 0, NULLCHAR,
  466. #ifdef    SCC
  467.     "sccstat",    dosccstat,    0, 0, NULLCHAR,
  468. #endif
  469. #if    !defined(AMIGA)
  470.     "shell",    doshell,    0, 0, NULLCHAR,
  471. #endif
  472.     "smtp",        dosmtp,        0, 0, NULLCHAR,
  473.     "socket",    dosock,        0, 0, NULLCHAR,
  474. #ifdef    SERVERS
  475.     "start",    dostart,    0, 2, "start <servername>",
  476.     "stop",        dostop,        0, 2, "stop <servername>",
  477. #endif
  478.     "tcp",        dotcp,        0, 0, NULLCHAR,
  479.     "telnet",    dotelnet,    1024, 2, "telnet <address>",
  480.     "test",        dotest,        1024, 0, NULLCHAR,
  481.     "tip",        dotip,        256, 2, "tip <iface>",
  482. #ifdef    TRACE
  483.     "trace",    dotrace,    0, 0, NULLCHAR,
  484. #endif
  485.     "udp",        doudp,        0, 0, NULLCHAR,
  486.     "upload",    doupload,    0, 0, NULLCHAR,
  487. #ifdef    MSDOS
  488.     "watch",    doswatch,    0, 0, NULLCHAR,
  489. #endif
  490.     "?",        dohelp,        0, 0, NULLCHAR,
  491.     NULLCHAR,    NULLFP,        0, 0,
  492.         "Unknown command; type \"?\" for list",
  493. };
  494.  
  495. /* List of supported hardware devices */
  496. struct cmds Attab[] = {
  497. #ifdef    ASY
  498.     /* Ordinary PC asynchronous adaptor */
  499.     "asy", asy_attach, 0, 8,
  500. #ifndef    AMIGA
  501.     "attach asy <address> <vector> slip|ax25|nrs|ppp <label> <buffers> <mtu> <speed> [ip_addr]",
  502. #else
  503.     "attach asy <driver> <unit> slip|ax25|nrs|ppp <label> <buffers> <mtu> <speed> [ip_addr]",
  504. #endif    /* AMIGA */
  505. #endif    /* ASY */
  506. #ifdef    PC100
  507.     /* PACCOMM PC-100 8530 HDLC adaptor */
  508.     "pc100", pc_attach, 0, 8,
  509.     "attach pc100 <address> <vector> ax25 <label> <buffers>\
  510.  <mtu> <speed> [ip_addra] [ip_addrb]",
  511. #endif
  512. #ifdef    DRSI
  513.     /* DRSI PCPA card in low speed mode */
  514.     "drsi", dr_attach, 0, 8,
  515.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu>\
  516. <chan a speed> <chan b speed> [ip addr a] [ip addr b]",
  517. #endif
  518. #ifdef    EAGLE
  519.     /* EAGLE RS-232C 8530 HDLC adaptor */
  520.     "eagle", eg_attach, 0, 8,
  521.     "attach eagle <address> <vector> ax25 <label> <buffers>\
  522.  <mtu> <speed> [ip_addra] [ip_addrb]",
  523. #endif
  524. #ifdef    PI
  525.     /* PI 8530 HDLC adaptor */
  526.     "pi", pi_attach, 0, 8,
  527.     "attach pi <address> <vector> <dmachannel> ax25 <label> <buffers>\
  528.  <mtu> <speed> [ip_addra] [ip_addrb]",
  529. #endif
  530. #ifdef    HAPN
  531.     /* Hamilton Area Packet Radio (HAPN) 8273 HDLC adaptor */
  532.     "hapn", hapn_attach, 0, 8,
  533.     "attach hapn <address> <vector> ax25 <label> <rx bufsize>\
  534.  <mtu> csma|full [ip_addr]",
  535. #endif
  536. #ifdef    APPLETALK
  537.     /* Macintosh AppleTalk */
  538.     "0", at_attach, 0, 7,
  539.     "attach 0 <protocol type> <device> arpa <label> <rx bufsize> <mtu> [ip_addr]",
  540. #endif
  541. #ifdef NETROM
  542.     /* fake netrom interface */
  543.     "netrom", nr_attach, 0, 1,
  544.     "attach netrom [ip_addr]",
  545. #endif
  546. #ifdef    PACKET
  547.     /* FTP Software's packet driver spec */
  548.     "packet", pk_attach, 0, 4,
  549.     "attach packet <int#> <label> <buffers> <mtu> [ip_addr]",
  550. #endif
  551. #ifdef    HS
  552.     /* Special high speed driver for DRSI PCPA or Eagle cards */
  553.     "hs", hs_attach, 0, 7,
  554.     "attach hs <address> <vector> ax25 <label> <buffers> <mtu>\
  555.  <txdelay> <persistence> [ip_addra] [ip_addrb]",
  556. #endif
  557. #ifdef SCC
  558.     "scc", scc_attach, 0, 7,
  559.     "attach scc <devices> init <addr> <spacing> <Aoff> <Boff> <Dataoff>\n"
  560.     "   <intack> <vec> [p]<clock> [hdwe] [param]\n"
  561.     "attach scc <chan> slip|kiss|nrs|ax25 <label> <mtu> <speed> <bufsize> [call] ",
  562. #endif
  563.     NULLCHAR,
  564. };
  565.  
  566. /* Functions to be called on each clock tick */
  567. void (*Cfunc[])() = {
  568.     pctick,    /* Call PC-specific stuff to keep time */
  569.     kbint,    /* Necessary because there's no hardware keyboard interrupt */
  570.     refiq,    /* Replenish interrupt pool */
  571. #ifdef    ASY
  572.     asytimer,
  573. #endif
  574. #ifdef    SCC
  575.     scctimer,
  576. #endif
  577.     NULL,
  578. };
  579.  
  580. /* Entry points for garbage collection */
  581. void (*Gcollect[])() = {
  582.     tcp_garbage,
  583.     ip_garbage,
  584.     udp_garbage,
  585.     st_garbage,
  586. #ifdef    AX25
  587.     lapb_garbage,
  588. #endif
  589. #ifdef    NETROM
  590.     nr_garbage,
  591. #endif
  592.     NULL
  593. };
  594.  
  595. /* Functions to be called at shutdown */
  596. void (*Shutdown[])() = {
  597. #ifdef    SCC
  598.     sccstop,
  599. #endif
  600.     uchtimer,    /* Unlink timer handler from timer chain */
  601.     NULLVFP,
  602. };
  603.  
  604. /* Packet tracing stuff */
  605. #ifdef    TRACE
  606. #include "trace.h"
  607.  
  608. /* Protocol tracing function pointers. Matches list of class definitions
  609.  * in pktdrvr.h.
  610.  */
  611. struct trace Tracef[] = {
  612.     NULLFP,        ip_dump,    /* CL_NONE */
  613.  
  614. #ifdef    ETHER                /* CL_ETHERNET */
  615.     ether_forus,    ether_dump,
  616. #else
  617.     NULLFP,        NULLVFP,
  618. #endif    /* ETHER */
  619.  
  620.     NULLFP,        NULLVFP,    /* CL_PRONET_10 */
  621.     NULLFP,        NULLVFP,    /* CL_IEEE8025 */
  622.     NULLFP,        NULLVFP,    /* CL_OMNINET */
  623.  
  624. #ifdef    APPLETALK
  625.     at_forus,    at_dump,    /* CL_APPLETALK */
  626. #else
  627.     NULLFP,        NULLVFP,
  628. #endif    /* APPLETALK */
  629.  
  630. #ifdef VJCOMPRESS
  631.     NULLFP,        sl_dump,    /* CL_SERIAL_LINE */
  632. #else
  633.     NULLFP,        ip_dump,    /* CL_SERIAL_LINE */
  634. #endif
  635.     NULLFP,        NULLVFP,    /* CL_STARLAN */
  636.  
  637. #ifdef    ARCNET
  638.     arc_forus,    arc_dump,    /* CL_ARCNET */
  639. #else
  640.     NULLFP,        NULLVFP,
  641. #endif    /* ARCNET */
  642.  
  643. #ifdef    AX25
  644.     ax_forus,    ax25_dump,    /* CL_AX25 */
  645. #else
  646.     NULLFP,        NULLVFP,
  647. #endif    /* AX25 */
  648.  
  649. #ifdef    KISS                /* CL_KISS */
  650.     ki_forus,    ki_dump,
  651. #else
  652.     NULLFP,        NULLVFP,
  653. #endif    /* KISS */
  654.  
  655.     NULLFP,        NULLVFP,    /* CL_IEEE8023 */
  656.     NULLFP,        NULLVFP,    /* CL_FDDI */
  657.     NULLFP,        NULLVFP,    /* CL_INTERNET_X25 */
  658.     NULLFP,        NULLVFP,    /* CL_LANSTAR */
  659.     NULLFP,        ip_dump,    /* CL_SLFP */
  660.  
  661. #ifdef    NETROM                /* CL_NETROM */
  662.     NULLFP,        ip_dump,
  663. #else
  664.     NULLFP,        NULLVFP,
  665. #endif
  666.  
  667. #ifdef PPP
  668.     NULLFP,        ppp_dump,    /* CL_PPP */
  669. #else
  670.     NULLFP,        NULLVFP,
  671. #endif /* PPP */
  672. };
  673.  
  674. #else    /* TRACE */
  675.  
  676. /* Stub for packet dump function */
  677. void
  678. dump(iface,direction,type,bp)
  679. struct iface *iface;
  680. int direction;
  681. unsigned type;
  682. struct mbuf *bp;
  683. {
  684. }
  685. void
  686. raw_dump(iface,direction,bp)
  687. struct iface *iface;
  688. int direction;
  689. struct mbuf *bp;
  690. {
  691. }
  692.  
  693. #endif    /* TRACE */
  694.  
  695.  
  696. #ifndef    TRACEBACK
  697. void
  698. stktrace()
  699. {
  700. }
  701. #endif
  702.  
  703. #ifndef    LZW
  704. void
  705. lzwfree(up)
  706. struct usock *up;
  707. {
  708. }
  709. #endif
  710.  
  711. #ifdef    AX25
  712. /* Hooks for passing incoming AX.25 data frames to network protocols */
  713. static void
  714. axip(iface,axp,src,dest,bp,mcast)
  715. struct iface *iface;
  716. struct ax25_cb *axp;
  717. char *src;
  718. char *dest;
  719. struct mbuf *bp;
  720. int mcast;
  721. {
  722.     (void)ip_route(iface,bp,mcast);
  723. }
  724.  
  725. static void
  726. axarp(iface,axp,src,dest,bp,mcast)
  727. struct iface *iface;
  728. struct ax25_cb *axp;
  729. char *src;
  730. char *dest;
  731. struct mbuf *bp;
  732. int mcast;
  733. {
  734.     (void)arp_input(iface,bp);
  735. }
  736.  
  737. #ifdef    NETROM
  738. static void
  739. axnr(iface,axp,src,dest,bp,mcast)
  740. struct iface *iface;
  741. struct ax25_cb *axp;
  742. char *src;
  743. char *dest;
  744. struct mbuf *bp;
  745. int mcast;
  746. {
  747.     if(!mcast)
  748.         nr_route(bp,axp);
  749.     else
  750.         nr_nodercv(iface,src,bp);
  751. }
  752.  
  753. #endif    /* NETROM */
  754. #endif    /* AX25 */
  755.  
  756. #ifndef    RIP
  757. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  758. void
  759. rt_timeout(s)
  760. void *s;
  761. {
  762.     struct route *stale = (struct route *)s;
  763.  
  764.     rt_drop(stale->target,stale->bits);
  765. }
  766. #endif
  767.  
  768. /* Stubs for demand dialer */
  769. #ifndef    DIALER
  770. void
  771. dialer_kick(asyp)
  772. struct asy *asyp;
  773. {
  774. }
  775. #endif
  776.  
  777. /* Stubs for Van Jacobsen header compression */
  778. #if !defined(VJCOMPRESS) && defined(ASY)
  779. struct slcompress *
  780. slhc_init(rslots,tslots)
  781. int rslots;
  782. int tslots;
  783. {
  784.     return NULLSLCOMPR;
  785. }
  786. int
  787. slhc_compress(comp, bpp, compress_cid)
  788. struct slcompress *comp;
  789. struct mbuf **bpp;
  790. int compress_cid;
  791. {
  792.     return SL_TYPE_IP;
  793. }
  794. int
  795. slhc_uncompress(comp, bpp)
  796. struct slcompress *comp;
  797. struct mbuf **bpp;
  798. {
  799.     return -1;    /* Can't decompress */
  800. }
  801. void
  802. shlc_i_status(comp)
  803. struct slcompress *comp;
  804. {
  805. }
  806. void
  807. shlc_o_status(comp)
  808. struct slcompress *comp;
  809. {
  810. }
  811. int
  812. slhc_remember(comp, bpp)
  813. struct slcompress *comp;
  814. struct mbuf **bpp;
  815. {
  816.     return -1;
  817. }
  818. #endif /* !defined(VJCOMPRESS) && defined(ASY) */
  819.  
  820. #ifdef    SERVERS
  821. /* "start" and "stop" subcommands */
  822. static struct cmds Startcmds[] = {
  823. #if    defined(AX25) && defined(MAILBOX)
  824.     "ax25",        ax25start,    256, 0, NULLCHAR,
  825. #endif
  826.     "discard",    dis1,        256, 0, NULLCHAR,
  827.     "echo",        echo1,        256, 0, NULLCHAR,
  828.     "finger",    finstart,    256, 0, NULLCHAR,
  829.     "ftp",        ftpstart,    256, 0, NULLCHAR,
  830. #if    defined(NETROM) && defined(MAILBOX)
  831.     "netrom",    nr4start,    256, 0, NULLCHAR,
  832. #endif
  833. #ifdef POP
  834.     "pop",        pop1,        256, 0, NULLCHAR,
  835. #endif
  836. #ifdef    RIP
  837.     "rip",        doripinit,    0,   0, NULLCHAR,
  838. #endif
  839.     "smtp",        smtp1,        256, 0, NULLCHAR,
  840. #if    defined(MAILBOX)
  841.     "telnet",    telnet1,    256, 0, NULLCHAR,
  842.     "tip",        tipstart,    256, 2, "start tip <interface>",
  843. #endif
  844.     "ttylink",    ttylstart,    256, 0, NULLCHAR,
  845.     "remote",    rem1,        768, 0, NULLCHAR,
  846.     NULLCHAR,
  847. };
  848. static struct cmds Stopcmds[] = {
  849. #if    defined(AX25) && defined(MAILBOX)
  850.     "ax25",        ax250,        0, 0, NULLCHAR,
  851. #endif
  852.     "discard",    dis0,        0, 0, NULLCHAR,
  853.     "echo",        echo0,        0, 0, NULLCHAR,
  854.     "finger",    fin0,        0, 0, NULLCHAR,
  855.     "ftp",        ftp0,        0, 0, NULLCHAR,
  856. #if    defined(NETROM) && defined(MAILBOX)
  857.     "netrom",    nr40,        0, 0, NULLCHAR,
  858. #endif
  859. #ifdef    POP
  860.     "pop",        pop0,        0, 0, NULLCHAR,
  861. #endif
  862. #ifdef    RIP
  863.     "rip",        doripstop,    0, 0, NULLCHAR,
  864. #endif
  865.     "smtp",        smtp0,        0, 0, NULLCHAR,
  866. #ifdef    MAILBOX
  867.     "telnet",    telnet0,    0, 0, NULLCHAR,
  868.     "tip",        tip0,        0, 2, "stop tip <interface>",
  869. #endif
  870.     "ttylink",    ttyl0,        0, 0, NULLCHAR,
  871.     "remote",    rem0,        0, 0, NULLCHAR,
  872.     NULLCHAR,
  873.  
  874. };
  875. static int
  876. dostart(argc,argv,p)
  877. int argc;
  878. char *argv[];
  879. void *p;
  880. {
  881.     return subcmd(Startcmds,argc,argv,p);
  882. }
  883. static int
  884. dostop(argc,argv,p)
  885. int argc;
  886. char *argv[];
  887. void *p;
  888. {
  889.     return subcmd(Stopcmds,argc,argv,p);
  890. }
  891. #endif    /* SERVERS */
  892.  
  893. #ifdef    notdef
  894. int
  895. dotest(argc,argv,p)
  896. int argc;
  897. char *argv[];
  898. void *p;
  899. {
  900.     long i;
  901.     int32 oldtime = 0;
  902.     int32 newtime;
  903.  
  904.     Current->flowmode = 1;
  905.     for(i=0;i<40000;i++){
  906.         newtime = msclock();
  907.         if(newtime < oldtime){
  908.             tprintf("Clock slip %ld: %ld - %ld = %ld\n",i,
  909.                 newtime,oldtime,newtime-oldtime);
  910.         } else
  911.             oldtime = newtime;
  912.     }
  913.     pwait(NULL);
  914.     Current->flowmode = 0;
  915.     return 0;
  916. }
  917.  
  918. #endif
  919. int
  920. dotest(argc,argv,p)
  921. int argc;
  922. char *argv[];
  923. void *p;
  924. {
  925.     p = (void *)0x12345678;
  926.     free(p);
  927.     return 0;
  928. }
  929.